<template>
  <div>vuex
    {{ newUserInfo }}---{{ num }}
    <button @click="saveVuex">vuex存值</button>

  </div>
</template>

<script>
import { mapState, mapGetters, mapActions, mapMutations } from "vuex"
export default {
  components: {},
  props: {},
  data () {
    return {

    }
  },
  computed: {
    ...mapState('userInfo', ['userInfo', 'num']),
    ...mapGetters('userInfo', ['newUserInfo']),
    netUserINfo () {
      // return this.store.state.userInfo.userInfo ? this.store.state.userInfo.userInfo : localStorage.getItem("userInfo")
    }
  },
  methods: {
    saveVuex () {
      //   // dispatch触发action里面的方法
      //   // commit 触发的是mutations里面的方法
      // this.$store.dispatch("userInfo/saveValue", { name: "张宇航", sex: "男" })
      //   this.$store.commit("userInfo/saveVal", { name: "张宇航", sex: "男" })
      this.saveValue("传递参数");
      // this.$store.state.userInfo.num++
    },
    ...mapActions('userInfo', ['saveValue']),

  },
  created () {

  },
  mounted () {

  },
}
</script>
<style scoped></style>